{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">
        <div class="layui-btn-group">
            <a href="{:url('admin/category/models_field_add',['model'=>input('model')])}" class="layui-btn ajax-iframe" data-width="630px" data-height="480px"><i class="fa fa-plus-circle"></i> 添加</a>
        </div>
    </div>
    <table id="tableList" lay-filter="tableList"></table>
    <!-- 表格操作列 -->
    <script type="text/html" id="tableTBTrack">
        <a href="{:url('admin/category/models_field_edit')}?id={{d.id}}" class="layui-btn ajax-iframe layui-btn-sm" data-width="630px" data-height="480px">修改</a>
        <a href="{:url('admin/category/models_field_del')}?id={{d.id}}" class="layui-btn layui-btn-sm layui-btn-danger ajax-delete">删除</a>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="status">
        <input type="checkbox" name="status" lay-skin="switch" lay-filter="*" lay-text="启用|禁用" data-url="{:url('admin/category/models_field_edit')}?id={{d.id}}" {{d.status==1?'checked':''}}>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="sort_order">
        <input type="text" name="sort_order" value="{{d.sort_order}}" autocomplete="off" class="layui-input ajax-update" data-url="{:url('admin/category/models_field_edit')}?id={{d.id}}">
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="is_sys">
        {{# if(d.is_sys == '1'){ }}
        <button class="layui-btn layui-btn-danger layui-btn-xs">系统</button>
        {{# }else{ }}
        <button class="layui-btn layui-btn-primary layui-btn-xs">其他</button>
        {{# } }}
    </script>
</div>
{/block}
{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var dropdown = layui.dropdown;

        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('admin/category/models_field_json',['model'=>input('model')])}",
            page: true,
            cellMinWidth: 100,
            size:'lg',even:true,
            cols: [[
                {align: 'left', sort: true, title: '#',templet:'#is_sys',width:70},
                {field: 'title', align: 'left', sort: true, title: '标题'},
                {field: 'name', align: 'left', sort: true, title: '标识'},
                {field: 'type', align: 'left', sort: true, title: '类型'},
                {field: 'value', align: 'left', sort: true, title: '默认值'},
                {align: 'center', sort: true, title: '排序',templet:'#sort_order'},
                {align: 'center', sort: true, title: '状态',templet:'#status'},
                {align: 'center', toolbar: '#tableTBTrack', title: '操作',width:135}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });

    });

</script>
{/block}